Data-Unloading Functions
Compressors use the data-loading and data-unloading functions when working with images that do not fit into the computer's memory. The data-unloading function writes compressed data to a storage device during a compression operation.
The
FlushProcPtr
data type defines a pointer to a data-unloading function.
/* data-unloading structure */
typedef struct ICMFlushProcRecord ICMFlushProcRecord;
typedef ICMFlushProcRecord *ICMFlushProcRecordPtr;
You assign a data-unloading function to an image or a sequence by passing a pointer to a structure that identifies the function to the appropriate compression function.
The data-unloading function structure contains the following fields:
struct ICMFlushProcRecord
{
ICMFlushUPP flushProc; /* pointer to data-unloading function */
long flushRefCon;/* reference constant */
};
-
flushProc
-
Contains a pointer to your data-unloading function.
-
flushRefCon
-
Contains a reference constant for use by your data-unloading function.
MyDataUnloadingProc
Your data-unloading function should have the following form:
pascal OSErr MyDataUnloadingProc (Ptr data, long bytesAdded,
long refcon);
-
data
-
Points to the data buffer. The compressor uses this parameter to indicate where your data-unloading function can find the compressed data. You establish this data buffer when you start the compression operation. For example, the
data
parameter to the
FCompressImage
function (described on
FCompressImage
) defines the location of the data buffer for that operation. This pointer contains a 32-bit clean address. Your data-unloading function should make no other assumptions about the value of this address.
-
The compressor may also use this parameter to indicate that it wants to reset the mark within the compressed data stream. If the
data
parameter is set to
nil
, the
bytesNeeded
parameter contains the new mark position, relative to the current position of the output data stream. If your data-unloading function does not support this operation, return a nonzero result code.
-
bytesAdded
-
Specifies the number of bytes to write or the new mark offset. If the compressor wants to write out some compressed data (that is, the value of
data
is not
nil
), then this parameter specifies how many bytes to write. This value never exceeds the size of the original data buffer. Your data-unloading function should write that data at the current mark in the output data stream.
-
If the compressor has requested to set a new mark position in the output data stream (that is, the value of
data
is
nil
), then this parameter specifies the new mark position relative to the current position of the data stream.
-
refcon
-
Contains a reference constant value for use by your data-unloading function. Your application specifies the value of this reference constant in the data-unloading function structure you pass to the Image Compression Manager.
RESULT CODES
noErr
|
0
|
No error
|
paramErr
|
-50
|
Invalid parameter specified
|
codecSpoolErr
|
-8966
|
Error loading or unloading data
|
© 1997 Apple Computer, Inc.Previous | Chapter Top | Chapter Contents | Next